<?php


namespace app\api\middleware;


use app\admin\model\UserBase;
use app\common\traits\JumpTrait;
use think\Request;

/**
 * 银行职员身份验证
 * Class AdminCheck
 * @package app\wechat\middleware
 */
class AdminCheck
{
    use JumpTrait;
    public function handle(Request $request, \Closure $next)
    {
        $client_type = session('client_type');
        if ($client_type == '') {//支付宝授权
        //TODO
        } elseif ($client_type == 'wechat') {//微信授权
            $user = session('wechat_user');
            $author_list = UserBase::where('id','=', $user['user_id'])->value('user_author');
            if (!in_array(3, str2arr($author_list))) {
                $this->error('用户权限不足');
            }
        }
        return $next($request);
    }


}